//
//  MTTagCollectionViewCell.swift
//  MT
//
//  Created by M on 2020/1/5.
//  Copyright © 2020 张强. All rights reserved.
//

import UIKit
import MTCategory

class MTTagCollectionViewCell: UICollectionViewCell {
    
    var model: MTTagModel? {
        didSet {
            guard let model = model else { return }
            nameLabel.text = model.name
            
            if colorStyle == .backgroundBlack {
                
                nameLabel.backgroundColor = .clear
                nameLabel.textColor = UIColor.theme.main
                nameLabel.layer.borderWidth = 1
                nameLabel.layer.borderColor = UIColor.theme.main.cgColor
                
            } else if colorStyle == .background0x161616 {
                
                nameLabel.backgroundColor = model.tagged == 0 ? .clear : UIColor.theme.main
                nameLabel.textColor = model.tagged == 0 ? .white : UIColor.common.x161616
                nameLabel.layer.borderWidth = model.tagged == 0 ? 1 : 0
                
            }
            
        }
    }
    
    var colorStyle: MTTagCollectionView.ColorStyle = .background0x161616 {
        didSet {
            
        }
    }
    
    /// Tag Name Label
    lazy var nameLabel: UILabel = {
        let label = UILabel()
        label.font = PingFangSCMediumFont(12)
        label.textColor = .white
        label.layer.borderColor = UIColor.white.cgColor
        label.layer.borderWidth = 1
        label.textAlignment = .center
        label.layer.cornerRadius = 13
        label.clipsToBounds = true
        return label
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initializeUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

// MARK: ------------------------------------ Overrides ----------------------------------------
extension MTTagCollectionViewCell {
    
    private func initializeUI() {
        contentView.addSubview(nameLabel)
        nameLabel.snp.makeConstraints { (make) in
            make.edges.equalTo(contentView)
        }
    }
    
}

// MARK: ------------------------------------ 初始化 ----------------------------------------
extension MTTagCollectionViewCell {
    
}
